package mainClient;

import interaction.ProtocolType;

public class ClientFactory
{
  private IClient makeUdpClient(int port, int selfPort, String ip)
  {
    return new UdpClient(port, ip, selfPort);
  }
  
  private IClient makeTcpClient(int port, int selfPort, String ip)
  {
    return new TcpClient(port, ip, selfPort);
  }
  
  private IClient makeRmIClient(int port, int selfPort, String ip)
  {
    return new RmiClient(port, ip, selfPort);
  }
  
  private IClient makeCorbaClient(int port, int selfPort, String ip)
  {
    return new CorbaClient(port, ip, selfPort);
  }
  
  public IClient makeClient(ProtocolType type, int port, int selfPort, String ip)
  {
    switch (type)
    {
    case UDP:
      return makeUdpClient(port, selfPort, ip);      
    case TCP:
      return makeTcpClient(port, selfPort, ip);      
    case RMI:
      return makeRmIClient(port, selfPort, ip);      
    case CORBA:
      return makeCorbaClient(port, selfPort, ip);
    default:
      System.out.println("Недопустимый тип протокола");
      return null;
    }
  }
}
